﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Logging;
using VAdvantage.Utility;
using System.Data.SqlClient;
using System.Text;
using VAdvantage.Model;
using System.Data;
using VAdvantage.Classes;
using VAdvantage.DataBase;
using System.Threading;
using System.Windows.Threading;
using VAdvantage.DataService;
using System.Collections;
using System.Collections.ObjectModel;
using System.Reflection;
using VAdvantage.Controls;
using VAdvantage.Framework;

namespace VAdvantage.Search
{
    public class InfoBPartner : Info
    {
        #region Private Variables
        //All the search control on the info window
        private VLabel labelValue = new VLabel();

        private VTextBox fieldValue = new VTextBox(HEIGHT);

        private VLabel labelName = new VLabel();
        private VTextBox fieldName = new VTextBox(HEIGHT);

        private VLabel labelContact = new VLabel();
        private VTextBox fieldContact = new VTextBox(HEIGHT);

        private VLabel labelEMail = new VLabel();
        private VTextBox fieldEMail = new VTextBox(HEIGHT);

        private VLabel labelPostal = new VLabel();
        private VTextBox fieldPostal = new VTextBox(HEIGHT);

        private VLabel labelPhone = new VLabel();
        private VTextBox fieldPhone = new VTextBox(HEIGHT);

        private VCheckBox checkAND = new VCheckBox();
        private VCheckBox checkCustomer = new VCheckBox();

        private bool _isSOTrx = false;

        String _value = "";
        String _name = "";
        String _contact = "";
        String _email = "";
        String _phone = "";
        String _postal = "";
        bool _AND = false;
        bool _customer = false;
        #endregion

        public InfoBPartner(Object frame, bool modal, int WindowNo, String value, bool isSOTrx, bool multiSelection, String whereClause)
            : base(frame, modal, WindowNo, "C_BPartner", "C_BPartner_ID", multiSelection, whereClause)
        {
            base.SetTitle(Msg.GetMsg(Utility.Envs.GetContext(), "InfoBPartner"));
            _isSOTrx = isSOTrx;
            StartInit();
            InitInfo(value, whereClause);

            int no = 0;

            base.SetStatusMsg(no + " " + Msg.GetMsg(Utility.Envs.GetContext(), "SearchRows_EnterQuery"));
            if (value != null && value.Length > 0)
                ExecuteQuery();
            _LoadedOK = true;

        }

        /** From Clause             */
        private static String _partnerFROM = "C_BPartner"
            + " LEFT OUTER JOIN C_BPartner_Location l ON (C_BPartner.C_BPartner_ID=l.C_BPartner_ID AND l.IsActive='Y')"
            + " LEFT OUTER JOIN AD_User c ON (C_BPartner.C_BPartner_ID=c.C_BPartner_ID AND (c.C_BPartner_Location_ID IS NULL OR c.C_BPartner_Location_ID=l.C_BPartner_Location_ID) AND c.IsActive='Y')"
            + " LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)";


        /// <summary>
        /// Initilizes the info queries and key events
        /// </summary>
        /// <param _name="_value">_value being passed by the user through search controls</param>
        /// <param _name="whereClause">prepare where clause</param>
        private void InitInfo(String value, String whereClause)
        {
            //	Create Grid
            StringBuilder where = new StringBuilder();
            where.Append("C_BPartner.IsSummary='N' AND C_BPartner.IsActive='Y'");
            if (whereClause != null && whereClause.Length > 0)
                where.Append(" AND ").Append(whereClause);
            //
            PrepareTable(_partnerFROM, where.ToString(), "C_BPartner.Value");

            fieldValue.KeyDown += new KeyEventHandler(fieldValue_KeyDown);
            fieldName.KeyDown += new KeyEventHandler(fieldValue_KeyDown);
            fieldContact.KeyDown += new KeyEventHandler(fieldValue_KeyDown);
            fieldEMail.KeyDown += new KeyEventHandler(fieldValue_KeyDown);
            fieldPostal.KeyDown += new KeyEventHandler(fieldValue_KeyDown);
            fieldPhone.KeyDown += new KeyEventHandler(fieldValue_KeyDown);
            checkAND.Checked += new RoutedEventHandler(checkCustomer_Checked);
            checkAND.Unchecked += new RoutedEventHandler(checkCustomer_Checked);
            checkCustomer.Checked += new RoutedEventHandler(checkCustomer_Checked);
            checkCustomer.Unchecked += new RoutedEventHandler(checkCustomer_Checked);
            vdgvRecords.AutoGeneratingColumn += new EventHandler<DataGridAutoGeneratingColumnEventArgs>(vdgvRecords_AutoGeneratingColumn);

            


            //  Get indexes
            for (int i = 0; i < _Layout.Length; i++)
            {
                if (_Layout[i].GetIDcolSQL().IndexOf("AD_User_ID") != -1)
                    _AD_User_ID_index = i;
                if (_Layout[i].GetIDcolSQL().IndexOf("C_BPartner_Location_ID") != -1)
                    _C_BPartner_Location_ID_index = i;
            }

            //  Set Value
            if (value == null)
                value = "%";
            if (!value.EndsWith("%"))
                value += "%";

            //	Put query string in Name if not numeric
            if (value.Equals("%"))
            {
                fieldName.Text = value;
                _name = value;
            }
            //	No Numbers entered
            else if ((value.IndexOf("0") + value.IndexOf("1") + value.IndexOf("2") + value.IndexOf("3") + value.IndexOf("4") + value.IndexOf("5")
                + value.IndexOf("6") + value.IndexOf("7") + value.IndexOf("8") + value.IndexOf("9")) == -10)
            {
                if (value.StartsWith("%"))
                {
                    fieldName.Text = value;
                    _name = value;
                }
                else
                {
                    fieldName.Text = "%" + value;
                    _name = "%" + value;
                }
            }
            //	Number entered
            else
            {
                fieldValue.Text = _value;
                _value = value;
            }
        }


        

        void fieldValue_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                Search();
            }
        }

        protected override void bRefresh_Click(object sender, RoutedEventArgs e)
        {
            Search();
           // base.bRefresh_Click(sender, e);
            
        }

        public void Search()
        {
            _value = fieldValue.Text.ToUpper();
            _name = fieldName.Text.ToUpper();
            _contact = fieldContact.Text.ToUpper();
            _phone = fieldPhone.Text.ToUpper();
            _email = fieldEMail.Text.ToUpper();
            _postal = fieldPostal.Text.ToUpper();
            _AND = (bool)checkAND.IsChecked;
            _customer = (bool)checkCustomer.IsChecked;

            ExecuteQuery();

            if (vdgvRecords.Columns.Count > 0)
                vdgvRecords.Columns[0].Visibility = System.Windows.Visibility.Collapsed;
        }

        void checkCustomer_Checked(object sender, RoutedEventArgs e)
        {
            _value = fieldValue.Text.ToUpper();
            _name = fieldName.Text.ToUpper();
            _contact = fieldContact.Text.ToUpper();
            _phone = fieldPhone.Text.ToUpper();
            _email = fieldEMail.Text.ToUpper();
            _postal = fieldPostal.Text.ToUpper();

            _AND = (bool)checkAND.IsChecked;
            _customer = (bool)checkCustomer.IsChecked;

            ExecuteQuery();

            if (vdgvRecords.Columns.Count > 0)
                vdgvRecords.Columns[0].Visibility = System.Windows.Visibility.Collapsed;

        }

        /// <summary>
        /// Sets the initial setting for the info window
        /// </summary>
        private void StartInit()
        {
            InfoSetting();

            labelValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            labelValue.Margin = new Thickness(0, 0, 5, 0);
            labelContact.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            labelContact.Margin = new Thickness(0, 0, 5, 0);
            labelName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            labelName.Margin = new Thickness(0, 0, 5, 0);
            labelEMail.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            labelEMail.Margin = new Thickness(0, 0, 5, 0);
            labelPostal.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            labelPostal.Margin = new Thickness(0, 0, 5, 0);
            labelPhone.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            labelPhone.Margin = new Thickness(0, 0, 5, 0);

            checkAND.Margin = new Thickness(5, 0, 0, 0);
            checkCustomer.Margin = new Thickness(5, 0, 0, 0);
            //checkAND.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            //checkCustomer.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;

            labelValue.Content = Msg.GetMsg(Utility.Envs.GetContext(), "Value");
            labelName.Content = Msg.GetMsg(Utility.Envs.GetContext(), "Name");
            labelContact.Content = Msg.GetMsg(Utility.Envs.GetContext(), "Contact");
            labelEMail.Content = Msg.GetMsg(Utility.Envs.GetContext(), "EMail");
            labelPostal.Content = Msg.GetMsg(Utility.Envs.GetContext(), "Postal");
            labelPhone.Content = Msg.GetMsg(Utility.Envs.GetContext(), "Phone");

            checkAND.Content = Msg.GetMsg(Utility.Envs.GetContext(), "SearchAND");
            //tooltip.SetToolTip(checkAND, Utility.Msg.GetMsg(Utility.Envs.GetContext(), "SearchANDInfo"));

            if (_isSOTrx)
            {
                checkCustomer.Content = Msg.GetMsg(Utility.Envs.GetContext(), "OnlyCustomers");
            }
            else
            {
                checkCustomer.Content = Msg.GetMsg(Utility.Envs.GetContext(), "OnlyVendors");
            }

            checkAND.IsChecked = true;
            _AND = true;
            checkCustomer.IsChecked = true;
            _customer = true;

            Grid.SetRow(labelValue, 0);
            Grid.SetColumn(labelValue, 0);
            this.tablePanel.Children.Add(labelValue);
            //this.fieldValue.Dock = System.Windows.Forms.DockStyle.Fill;

            Grid.SetRow(fieldValue, 0);
            Grid.SetColumn(fieldValue, 1);
            this.tablePanel.Children.Add(fieldValue);

            //tablePanel.Controls.Add(fieldValue, 1, 0);

            Grid.SetRow(labelName, 1);
            Grid.SetColumn(labelName, 0);
            this.tablePanel.Children.Add(labelName);
            //tablePanel.Controls.Add(labelName, 0, 1);
            //this.fieldName.Dock = System.Windows.Forms.DockStyle.Fill;

            Grid.SetRow(fieldName, 1);
            Grid.SetColumn(fieldName, 1);
            this.tablePanel.Children.Add(fieldName);
            //tablePanel.Controls.Add(fieldName, 1, 1);

            Grid.SetRow(labelEMail, 0);
            Grid.SetColumn(labelEMail, 2);
            this.tablePanel.Children.Add(labelEMail);
            //tablePanel.Controls.Add(labelEMail, 2, 0);
            //this.fieldEMail.Dock = System.Windows.Forms.DockStyle.Fill;

            Grid.SetRow(fieldEMail, 0);
            Grid.SetColumn(fieldEMail, 3);
            this.tablePanel.Children.Add(fieldEMail);
            //tablePanel.Controls.Add(fieldEMail, 3, 0);

            Grid.SetRow(labelContact, 1);
            Grid.SetColumn(labelContact, 2);
            this.tablePanel.Children.Add(labelContact);
            //tablePanel.Controls.Add(labelContact, 2, 1);
            //this.fieldContact.Dock = System.Windows.Forms.DockStyle.Fill;

            Grid.SetRow(fieldContact, 1);
            Grid.SetColumn(fieldContact, 3);
            this.tablePanel.Children.Add(fieldContact);
            //tablePanel.Controls.Add(fieldContact, 3, 1);

            Grid.SetRow(labelPhone, 0);
            Grid.SetColumn(labelPhone, 4);
            this.tablePanel.Children.Add(labelPhone);
            //tablePanel.Controls.Add(labelPhone, 4, 0);
            //this.fieldPhone.Dock = System.Windows.Forms.DockStyle.Fill;

            Grid.SetRow(fieldPhone, 0);
            Grid.SetColumn(fieldPhone, 5);
            this.tablePanel.Children.Add(fieldPhone);
            //tablePanel.Controls.Add(fieldPhone, 5, 0);


            Grid.SetRow(labelPostal, 1);
            Grid.SetColumn(labelPostal, 4);
            this.tablePanel.Children.Add(labelPostal);
            //tablePanel.Controls.Add(labelPostal, 4, 1);
            //this.fieldPostal.Dock = System.Windows.Forms.DockStyle.Fill;


            Grid.SetRow(fieldPostal, 1);
            Grid.SetColumn(fieldPostal, 5);
            this.tablePanel.Children.Add(fieldPostal);
            //tablePanel.Controls.Add(fieldPostal, 5, 1);


            checkAND.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            //checkAND.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Grid.SetRow(checkAND, 0);
            Grid.SetColumn(checkAND, 6);
            this.tablePanel.Children.Add(checkAND);
            //tablePanel.Controls.Add(, 6, 0);


            checkCustomer.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            //checkCustomer.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            Grid.SetRow(checkCustomer, 1);
            Grid.SetColumn(checkCustomer, 6);
            this.tablePanel.Children.Add(checkCustomer);
            //tablePanel.Controls.Add(checkCustomer, 6, 1);

            //location of the controls

        }

        private const int HEIGHT = 23;
        /// <summary>
        /// Sets the display setting
        /// </summary>
        protected void InfoSetting()
        {
            RowDefinition row = new RowDefinition();
            row.Height = new GridLength(0, GridUnitType.Auto);
            row.MinHeight = 30;
            this.tablePanel.RowDefinitions.Add(row);

            row = new RowDefinition();
            row.Height = new GridLength(0, GridUnitType.Auto);
            row.MinHeight = 30;
            this.tablePanel.RowDefinitions.Add(row);


            ColumnDefinition column = new ColumnDefinition();
            column.Width = new GridLength(25, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

            column = new ColumnDefinition();
            column.Width = new GridLength(45, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

            column = new ColumnDefinition();
            column.Width = new GridLength(25, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

            column = new ColumnDefinition();
            column.Width = new GridLength(45, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

            column = new ColumnDefinition();
            column.Width = new GridLength(25, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

            column = new ColumnDefinition();
            column.Width = new GridLength(45, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

            column = new ColumnDefinition();
            column.Width = new GridLength(35, GridUnitType.Star);
            this.tablePanel.ColumnDefinitions.Add(column);

        }


        public override string GetSQLWhere()
        {


            List<String> list = new List<String>();
            //	=> Value

            // Dispatcher.BeginInvoke(delegate() { _value = fieldValue.Text.ToUpper(); });
            if (!(_value.Equals("") || _value.Equals("%")))
                list.Add("UPPER(C_BPartner.Value) LIKE @param1");
            //	=> Name
          //  Dispatcher.BeginInvoke(delegate() { _name = fieldName.Text.ToUpper(); });
            if (!(_name.Equals("") || _name.Equals("%")))
                list.Add("UPPER(C_BPartner.Name) LIKE @param2");
            //	=> Contact
            Dispatcher.BeginInvoke(delegate() { _contact = fieldContact.Text.ToUpper(); });
            if (!(_contact.Equals("") || _contact.Equals("%")))
                list.Add("UPPER(c.Name) LIKE @param3");
            //	=> EMail
            Dispatcher.BeginInvoke(delegate() { _email = fieldEMail.Text.ToUpper(); });
            if (!(_email.Equals("") || _email.Equals("%")))
                list.Add("UPPER(c.EMail) LIKE @param4");
            //	=> Phone
            Dispatcher.BeginInvoke(delegate() { _phone = fieldPhone.Text.ToUpper(); });
            if (!(_phone.Equals("") || _phone.Equals("%")))
                list.Add("UPPER(c.Phone) LIKE @param5");
            //	=> Postal
            Dispatcher.BeginInvoke(delegate() { _postal = fieldPostal.Text.ToUpper(); });
            if (!(_postal.Equals("") || _postal.Equals("%")))
                list.Add("UPPER(a.Postal) LIKE @param6");

            StringBuilder sql = new StringBuilder();
            int size = list.Count;
            //	Just one
            if (size == 1)
                sql.Append(" AND ").Append(list[0]);
            else if (size > 1)
            {
                Dispatcher.BeginInvoke(delegate() { _AND = (bool)checkAND.IsChecked; });
                sql.Append(" AND ");
                if (!_AND)
                    sql.Append("(");
                for (int i = 0; i < size; i++)
                {
                    if (i > 0)
                        sql.Append(_AND ? " AND " : " OR ");
                    sql.Append(list[i]);
                }
                if (!_AND)
                    sql.Append(")");
            }

            //	Static SQL
           // Dispatcher.BeginInvoke(delegate() { _customer = (bool)checkCustomer.IsChecked; });
            if (_customer)
            {
                sql.Append(" AND ");
                if (_isSOTrx)
                    sql.Append("C_BPartner.IsCustomer='Y'");
                else
                    sql.Append("C_BPartner.IsVendor='Y'");
            }
            return sql.ToString();
        }

        public override void SetParameters(out System.Data.SqlClient.SqlParameter[] param, bool forCount)
        {

            int paramcount = 0;
            if (!(_value.Equals("") || _value.Equals("%")))
                paramcount++;
            if (!(_name.Equals("") || _name.Equals("%")))
                paramcount++;
            if (!(_contact.Equals("") || _contact.Equals("%")))
                paramcount++;
            if (!(_email.Equals("") || _email.Equals("%")))
                paramcount++;
            if (!(_phone.Equals("") || _phone.Equals("%")))
                paramcount++;
            if (!(_postal.Equals("") || _postal.Equals("%")))
                paramcount++;

            param = new SqlParameter[paramcount];
            int index = 0;
            //	=> Value
            if (!(_value.Equals("") || _value.Equals("%")))
            {
                if (!_value.EndsWith("%"))
                    _value += "%";
                param[index++] = new SqlParameter("@param1", _value);
                //log.fine("Value: " + _value);
            }
            //	=> Name
            if (!(_name.Equals("") || _name.Equals("%")))
            {
                if (!_name.EndsWith("%"))
                    _name += "%";
                param[index++] = new SqlParameter("@param2", _name.ToUpper());
                //log.fine("Name: " + _name);
            }
            //	=> Contact
            if (!(_contact.Equals("") || _contact.Equals("%")))
            {
                if (!_contact.EndsWith("%"))
                    _contact += "%";
                param[index++] = new SqlParameter("@param3", _contact);
                //log.fine("Contact: " + _contact);
            }
            //	=> EMail
            if (!(_email.Equals("") || _email.Equals("%")))
            {
                if (!_email.EndsWith("%"))
                    _email += "%";
                param[index++] = new SqlParameter("@param4", _email);
                //log.fine("EMail: " + _email);
            }
            //	=> Phone
            if (!(_phone.Equals("") || _phone.Equals("%")))
            {
                if (!_phone.EndsWith("%"))
                    _phone += "%";
                param[index++] = new SqlParameter("@param5", _phone);
                //log.fine("Phone: " + _phone);
            }
            //	=> Postal

            if (!(_postal.Equals("") || _postal.Equals("%")))
            {
                if (!_postal.EndsWith("%"))
                    _postal += "%";
                param[index++] = new SqlParameter("@param6", _postal);
                //log.fine("Postal: " + _postal);
            }
        }



        private int _AD_User_ID_index = -1;
        private int _C_BPartner_Location_ID_index = -1;
        /// <summary>
        /// Saves the selection detail
        /// </summary>
        public override void SaveSelectionDetail()
        {
            //if (vdgvRecords.CurrentCell == null)
            //{
            //    return;
            //}
            int row = vdgvRecords.SelectedIndex;
            if (row == -1)
                return;

            int AD_User_ID = 0;
            int C_BPartner_Location_ID = 0;

            var type = vdgvRecords.SelectedItem.GetType();
            
            if (_AD_User_ID_index != -1)
            {
                PropertyInfo objPropInfo = type.GetProperty(_Layout[_AD_User_ID_index].GetColHeader());

                if (objPropInfo != null)
                {
                    Object data = objPropInfo.GetValue(vdgvRecords.SelectedItem, null);
                    if (data.GetType() == typeof(KeyNamePair))
                        AD_User_ID = ((KeyNamePair)data).GetKey();
                }
                //AD_User_ID = data.ToString() != "" ? int.Parse(data.ToString()) : 0;
            }
            if (_C_BPartner_Location_ID_index != -1)
            {
                PropertyInfo objPropInfo = type.GetProperty(_Layout[_C_BPartner_Location_ID_index].GetColHeader());
                if (objPropInfo != null)
                {
                    Object data = objPropInfo.GetValue(vdgvRecords.SelectedItem, null);
                    if (data.GetType() == typeof(KeyNamePair))
                        C_BPartner_Location_ID = ((KeyNamePair)data).GetKey();
                }
                //C_BPartner_Location_ID = data.ToString() != "" ? int.Parse(data.ToString()) : 0;
            }
            ////  publish for Callout to read
            int? ID = GetSelectedRowKey();
            Context ctx = Utility.Envs.GetContext();
            ctx.SetContext(Utility.Envs.WINDOW_INFO, Utility.Envs.TAB_INFO, "C_BPartner_ID", ID == null ? "0" : ID.ToString());
            ctx.SetContext(Utility.Envs.WINDOW_INFO, Utility.Envs.TAB_INFO, "AD_User_ID", AD_User_ID.ToString());
            ctx.SetContext(Utility.Envs.WINDOW_INFO, Utility.Envs.TAB_INFO, "C_BPartner_Location_ID", C_BPartner_Location_ID.ToString());
        }   //  saveSelectionDetail


        /**  Array of Column Info    */
        private static Info_Column[] _partnerLayout = {
		new Info_Column("V", "C_BPartner.C_BPartner_ID", typeof(IDColumn)),
		new Info_Column(Msg.Translate(Envs.GetContext(), "Value"), "C_BPartner.Value", typeof(String)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"Name"), "C_BPartner.Name", typeof(String)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"Contact"), "c.Name AS Contact", typeof(KeyNamePair), "c.AD_User_ID"),
		new Info_Column(Msg.Translate(Envs.GetContext(),"SO_CreditAvailable"), "C_BPartner.SO_CreditLimit-C_BPartner.SO_CreditUsed AS SO_CreditAvailable", typeof(Decimal), true, true, null),
		new Info_Column(Msg.Translate(Envs.GetContext(),"SO_CreditUsed"), "C_BPartner.SO_CreditUsed", typeof(Decimal)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"Phone"), "c.Phone", typeof(String)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"Postal"), "a.Postal", typeof(KeyNamePair), "l.C_BPartner_Location_ID"),
		new Info_Column(Msg.Translate(Envs.GetContext(),"City"), "a.City", typeof(String)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"TotalOpenBalance"), "C_BPartner.TotalOpenBalance", typeof(Decimal)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"Revenue"), "C_BPartner.ActualLifeTimeValue", typeof(Decimal)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"Address1"), "a.Address1", typeof(String)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"IsShipTo"), "l.IsShipTo", typeof(Boolean)),
		new Info_Column(Msg.Translate(Envs.GetContext(),"IsBillTo"), "l.IsBillTo", typeof(Boolean))
    	};

        /// <summary>
        /// Gets the info of columns
        /// </summary>
        /// <returns>Info_Column</returns>
        protected override Info_Column[] GetInfoColumns()
        {
            return _partnerLayout;
        }	//	getInfoColumns


        void vdgvRecords_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            foreach (DataGridColumn col in vdgvRecords.Columns)
            {
                if (col.DisplayIndex == 0 || col.DisplayIndex == 12)
                {
                    col.Visibility = Visibility.Collapsed;
                }
            }
        }

    }
}
